<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/11/22 0022
  Time: 上午 8:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<input type="text" id="qrText" />

        <button id="genQrCode">点我生成二维码（前台）
        </button>


    <div id="qrCode">


    </div>


<hr />

<button id="btn_genQrCode">点我生成二维码(后台)
</button>

<img id="qrImg">


<script src="https://cdn.bootcss.com/jquery/3.2.0/jquery.min.js"></script>
<script src="assets/js/qrcode.min.js"></script>

<script>
    window.onload=function(){

        var qrcode=new QRCode("qrCode",{
            width: 128,
            height: 128,
            colorDark : "#000000",
            colorLight : "#ffffff",
            correctLevel : QRCode.CorrectLevel.H
        });

        genQrCode.onclick=function(){
            qrcode.clear();
            qrcode.makeCode(document.getElementById("qrText").value);
        }

    }



    //通过后台生成二维码
   jQuery(function($){
       $(document).on("click","#btn_genQrCode",function(){
           $.get("/payment",function(data){
               console.log(data);
                if(data){
                    $("#qrImg").attr("src",data);
                }
           });
       })
   })

</script>

</body>
</html>